import java.util.Random;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-06-09
 * Time: 6:18
 */
class Dog{
    public String name;
    public String says;
}
public class Test {

    public static void main(String[] args) {

        int a = 170;
        int b = 85;
        System.out.println("^: " + Integer.toBinaryString(a^b));
        System.out.println("&: " + Integer.toBinaryString(a&b));
        System.out.println("|: " + Integer.toBinaryString(a|b));
        int i = -1;
        System.out.println(Integer.toBinaryString(i));
        i >>= 10;
        System.out.println(Integer.toBinaryString(i));
    }
    public static void main5(String[] args) {
        float f = 3.4028235e+38f;
        float f2 = 1.4e-45f;
        double d1 = 1.7976931348623157e+308;
        double d2 = 4.9e-324;
        System.out.println(f);
        System.out.println(f2);
        System.out.println(d1);
        System.out.println(d2);
        boolean b = true;
        boolean a = false;
        boolean c = a&b;
        c = a|b;
        c = a^b;
    }
    public static void main4(String[] args) {
        long l1 = 0x4f;
        long l2 = 0x4F;
        long l3 = 07;
        long l4 = 4;
        System.out.println("l3: " + Long.toBinaryString(l3));
        System.out.println("l4:" + Long.toBinaryString(l4));
        System.out.println("l1: " + Long.toBinaryString(l1));
        System.out.println("l1: " + Long.toBinaryString(l2));
        System.out.println("======================");
        float a = 1.0F;
        float b = 1f;
        float c = 1;
        long a1 = 200;
        long a2 = 2000L;
        int i1 = 0x2f;
        System.out.println("i1:" + Integer.toBinaryString(i1));
    }
    public static void main3(String[] args) {
        System.out.println("开始抛硬币:1.开始 2.退出");
        Scanner scanner = new Scanner(System.in);
        while( scanner.nextInt() == 1){
            Random random = new Random();
            int rand = random.nextInt(2) ;
            if(rand == 1){
                System.out.println("正面");
            }else{
                System.out.println("反面");
            }
            System.out.println("开始抛硬币:1.开始 2.退出");
        }
    }
    public static void main2(String[] args) {
        Dog dog1 = new Dog();
        dog1.name = "spot";
        dog1.says = "Ruff";
        Dog dog2 = new Dog();
        dog2.name = "scruffy";
        dog2.says = "Wurf";
        System.out.println(dog1.name + " " + dog1.says);
        System.out.println(dog2.name + " " + dog2.says);
        Dog dog3 = new Dog();
        dog3.name = "spot";
        System.out.println(dog1 == dog3);
        System.out.println(dog1.equals(dog3));
    }


    public static int findNthDigit(int n) {
        int nine = 9;
        int i;
        //确定n在哪个区间 15 -> [10,99]并且求出它是第几个数
        for(i = 1; i < 13; i++){
            n -= nine * i;
            if(n <= 0){
                n += nine * i;
                break;
            }
            nine *= 10;
        }
        int l = nine/9;
        int r = l*10 -1;
        int ans = 0;
        while(l <= r){
            int mid = (l + r) >> 1;
            //
            int cnt = (mid - nine/9 +1)*i;
            if(cnt < n){
                l = mid + 1;
            }else{
                r = mid - 1;
                ans = mid;
            }
        }
//        String s = new String(String.valueOf(ans));
//        ans = (int) s.charAt(s.length() - 1);
        Stack stk = new Stack();
        while(ans != 0){
            stk.push(ans%10);
            ans /=10;
        }

        return (int)stk.lastIndexOf(stk.get((n - 1) % i));
    }
    public static void main1(String[] args) {
        System.out.println(findNthDigit(11));
    }
}
